Skip to content

Conversation

@tcdent
Copy link
Owner

@tcdent tcdent commented Jan 30, 2026

Add define_tool_block! and define_simple_tool_block! macros to eliminate
repetitive boilerplate in tool block definitions. Each tool block now
only needs to specify the custom header rendering logic.

Refactored blocks:

  • ShellBlock, ReadFileBlock, WriteFileBlock, EditFileBlock
  • FetchUrlBlock, FetchHtmlBlock
  • ListAgentsBlock, GetAgentBlock
  • ListBackgroundTasksBlock, GetBackgroundTaskBlock

The macros generate:

  • Struct definition with standard fields
  • new() and from_params() constructors
  • Full Block trait implementation
  • Common render() structure (status, approval, result, denied)

This reduces ~870 lines of duplicated code to ~410 lines, with tool
blocks now being ~15-30 lines instead of ~70-100 lines each.

https://claude.ai/code/session_015xi85mutXbrHDKCU9WS511

Add define_tool_block! and define_simple_tool_block! macros to eliminate
repetitive boilerplate in tool block definitions. Each tool block now
only needs to specify the custom header rendering logic.

Refactored blocks:
- ShellBlock, ReadFileBlock, WriteFileBlock, EditFileBlock
- FetchUrlBlock, FetchHtmlBlock
- ListAgentsBlock, GetAgentBlock
- ListBackgroundTasksBlock, GetBackgroundTaskBlock

The macros generate:
- Struct definition with standard fields
- new() and from_params() constructors
- Full Block trait implementation
- Common render() structure (status, approval, result, denied)

This reduces ~870 lines of duplicated code to ~410 lines, with tool
blocks now being ~15-30 lines instead of ~70-100 lines each.

https://claude.ai/code/session_015xi85mutXbrHDKCU9WS511
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants